package lv.solcraft.replication.common;

import java.io.Serializable;

public class OperStateDTO implements Serializable {

    private final OperDTO oper;

    private final String state;

    private final String message;

    public OperStateDTO(OperDTO oper, String state, String message) {
        this.oper = oper;
        this.state = state;
        this.message = message;
    }

    public String getMessage() {
        return message;
    }

    public String getState() {
        return state;
    }

    public OperDTO getOper() {
        return oper;
    }

    public boolean isCommited() {
        return ReplicationConst.STATE_COMMITED.equals(state);
    }

    public boolean isError() {
        return ReplicationConst.STATE_ERROR.equals(state);
    }

    public boolean isIgnored() {
        return ReplicationConst.STATE_IGNORED.equals(state);
    }

    @Override
    public String toString() {
        return "[" + oper.getOperOwnerSiteId() + ":" + oper.getOperId() + ", " + state + ", " + message + "]";
    }

}
